//
// Created by 张闳 on 2021/12/13.
//

#include <map.h>
#include <logger.h>

struct people {
    uint64_t id;
    char name[20];
    uint8_t age;
};

int main(int argc, char* argv[]){
    log_init();
    log_set_level(LOG_DEBUG);
    map_t map;
    map = map_new();
    map_put(map,"key1","test value",10);
    struct people person={.id=10001,
            .name= "Bill Gates",
            .age=23,
            };
    map_put(map,"person:10001",&person,sizeof(person));
    uint16_t v = 123;
    map_put(map,"test.int",&v,2);
    char *v1 = (char *)map_get(map,"key1");
    struct people *p = (struct people *)map_get(map,"person:10001");
    uint16_t *v2 = (uint16_t *)map_get(map,"test.int");
    logDebug("key1 = %s, person.name = %s, person.age = %d, test.int = %u",v1,p->name,p->age,*v2);
    map_free(map);
}